import React from 'react';
import { Tabs,Card,Row,Col,Modal, Button, Collapse, Form, Input,InputNumber, Select, Radio,DatePicker,Spin,Icon, message } from 'antd';
import {idCardRegex, mobileRegex, telRegex} from "../../../utils/globalConst";
import Utils from './../../../utils/utils';
import moment from 'moment';
import Axios from "../../../axios";
import './index.less';
const TabPane = Tabs.TabPane;
const FormItem = Form.Item;
const RadioGroup = Radio.Group;
const Option = Select.Option;
const TextArea = Input.TextArea;
const CardGrid = Card.Grid;
const Panel = Collapse.Panel;

export default class UserDetails extends React.Component{
    state = {
    }
    componentDidMount(){
        //获取用户id
        let id = this.props.match.params.id;
        if(id){
            let params = {
                id,
            }
            this.detailsRequest(params);
        }
    }
    /*查询用户详情请求*/
    detailsRequest = (params)=>{
        this.setState({
            loading:true,
            loadingTxt:'加载中...'
        })
        Axios.get({
            block:'/hr',
            url:'/user/detail',
            params:params,
        }).then((data)=>{
            //console.log(data)
            let baseInfo = data.data;
            this.setState({
                loading:false,
                baseInfo,
            })
        }).catch((error)=>{
            this.setState({ loading:false })
            console.log(error);
        })
    }
    render(){
        const id = this.props.match.params.id;
        return (
            <Spin spinning={this.state.loading} size="large" tip={this.state.loadingTxt}>
                <div className="info-box">
                    <Card
                        bordered={false}
                        bodyStyle={{paddingLeft:0}}
                    >
                        <Tabs
                            defaultActiveKey="baseInfo"
                            animated={false}
                            tabPosition="left"
                        >
                            <TabPane tab="基础信息" key="baseInfo">
                                <BascInfo id={id} baseInfo={this.state.baseInfo}/>
                            </TabPane>
                            <TabPane tab="简历信息" key="resume">
                                <Resume id={id} baseInfo={this.state.baseInfo}/>
                            </TabPane>
                        </Tabs>

                    </Card>
                </div>
            </Spin>
        )
    }
}

//基础信息
export class BascInfo extends React.Component{
    state = {}
    componentDidMount(){
    }
    render(){
        const userBaseInfo = this.props.baseInfo||{};
        const genderDic = {
            'MAN':'男',
            'WOMAN':'女',
            'SECRECY':'保密',
        }
        return(
            <div className="basic-info common-details">
                <Card
                    title="用户基础信息"
                    bordered={false}
                    bodyStyle={{paddingLeft:0,paddingRight:0}}
                    headStyle={{paddingLeft:0,paddingRight:0}}
                >
                    <Row>
                        <Col>
                           {/* <div className="avatar"><img src="/assets/default_avatar.jpg" alt=""/></div>*/}
                            <div className="avatar"><img src={userBaseInfo.headPortrait?userBaseInfo.headPortrait:"/assets/default_avatar.jpg"} alt=""/></div>
                        </Col>
                    </Row>
                    <Row>
                        <Col sm={8} className="item"><span className="title">序号：</span><span className="details">{userBaseInfo.userNo}</span></Col>
                        <Col sm={8} className="item"><span className="title">名称：</span><span className="details">{userBaseInfo.name}</span></Col>
                        <Col sm={8} className="item"><span className="title">登录账号：</span><span className="details">{userBaseInfo.account}</span></Col>
                    </Row>
                    <Row>
                        <Col sm={8} className="item"><span className="title">真实姓名：</span><span className="details">{userBaseInfo.realname?userBaseInfo.realname:'—'}</span></Col>
                        <Col sm={8} className="item"><span className="title">身份证号码：</span><span className="details">{userBaseInfo.idcard?userBaseInfo.idcard:'—'}</span></Col>
                        <Col sm={8} className="item"><span className="title">生日：</span><span className="details">{userBaseInfo.birthDate?moment(userBaseInfo.birthDate).format("YYYY-MM-DD"):'—'}</span></Col>
                    </Row>
                    <Row>
                        <Col sm={8} className="item"><span className="title">性别：</span><span className="details">{genderDic[userBaseInfo.gender]}</span></Col>
                        <Col sm={8} className="item"><span className="title">手机号码：</span><span className="details">{userBaseInfo.mobile?userBaseInfo.mobile:'—'}</span></Col>
                        <Col sm={8} className="item"><span className="title">邮箱：</span><span className="details">{userBaseInfo.email?userBaseInfo.email:'—'}</span></Col>
                    </Row>
                    <Row>
                        <Col sm={8} className="item"><span className="title">入职时间：</span><span className="details">{userBaseInfo.hiredate?moment(userBaseInfo.hiredate).format("YYYY-MM-DD"):'—'}</span></Col>
                        <Col sm={8} className="item"><span className="title">行业工作时间：</span><span className="details">{userBaseInfo.beginIndustryJobTime?moment(userBaseInfo.beginIndustryJobTime).format("YYYY-MM-DD"):'—'}</span></Col>
                        <Col sm={8} className="item"><span className="title">行业工作年限：</span><span className="details">{userBaseInfo.serviceYear}</span></Col>
                    </Row>
                    <Row>
                        <Col sm={8} className="item"><span className="title">教育背景：</span><span className="details">{userBaseInfo.eduBackground?userBaseInfo.eduBackground:'—'}</span></Col>
                        <Col sm={8} className="item"><span className="title">职称：</span><span className="details">{userBaseInfo.jobTitle?userBaseInfo.jobTitle:'—'}</span></Col>
                        <Col sm={8} className="item"><span className="title">职位：</span><span className="details">{userBaseInfo.position?userBaseInfo.position:'—'}</span></Col>
                    </Row>
                    <Row>
                        <Col sm={8} className="item"><span className="title">岗位：</span><span className="details">{userBaseInfo.jobTitle?userBaseInfo.jobTitle:'—'}</span></Col>
                        <Col sm={8} className="item"><span className="title">部门：</span><span className="details">{userBaseInfo.position?userBaseInfo.position:'—'}</span></Col>
                    </Row>
                    <Row>
                        <Col sm={8} className="item"><span className="title">账号注册时间：</span><span className="details">{userBaseInfo.createTime}</span></Col>
                        <Col sm={8} className="item"><span className="title">信息更新时间：</span><span className="details">{userBaseInfo.updateTime}</span></Col>
                    </Row>
                </Card>
            </div>
        )
    }
}
//简历信息
export class Resume extends React.Component{
    state = {
        updateInfoModal:{
            visible: false,
            confirmLoading: false,
        },
        moreInfoModal:{
            visible: false,
            confirmLoading: false,
        }
    }
    componentDidMount(){
        //获取用户id
        let id = this.props.id;
        if(id){
            let params = { userId:id, }
            this.resumeBaseRequest(params);
        }
    }

    //编辑简历基础信息
    handleUpdateBaseInfo = ()=>{
        this.setState({
            updateInfoModal:{
                ...this.state.updateInfoModal,
                visible:true,
            }
        })
    }
    //简历基础信息 表单提交
    handleUpdateInfoSubmit = ()=>{
        const _form = this.updateInfoForm.props.form;
        _form.validateFields((err, values) => {
            if (err) {
                return;
            }
            //console.log(values)
            const birthDate = values['birthDate']?values['birthDate'].format('YYYY-MM-DD'):'';
            const beginIndustryJobTime = values['beginIndustryJobTime']?values['beginIndustryJobTime'].format('YYYY-MM-DD')+' 00:00:00':'';
            const beginJobTime = values['beginJobTime']?values['beginJobTime'].format('YYYY-MM-DD')+' 00:00:00':'';
            const eduGraduateTime = values['eduGraduateTime']?values['eduGraduateTime'].format('YYYY-MM-DD')+' 00:00:00':'';
            let params = {
                ...values,
                birthDate,
                beginIndustryJobTime,
                beginJobTime,
                eduGraduateTime
            }
            params = Utils.FilterParam(params); //过滤掉为空的参数
            //console.log(params)
            this.updateInfoRequest(params)
        });
    }
    //补充信息
    handleAddInfo = () =>{
        this.setState({
            moreInfoModal:{
                ...this.state.moreInfoModal,
                visible:true,
            }
        })
    }
    //补充信息编辑 表单提交
    handleMoreInfoSubmit = ()=>{
        const _form = this.moreInfoForm.props.form;
        _form.validateFields((err, values) => {
            //console.log(values);
            if (err) {
                return;
            }
            if (values.beginTime){
                values.beginTime=moment(values.beginTime).format("YYYY-MM-DD HH:mm:ss");
            }
            if (values.endTime){
                values.endTime=moment(values.endTime).format("YYYY-MM-DD HH:mm:ss");
            }
            let params = Utils.FilterParam(values); //过滤掉为空的参数
            this.createMoreInfoRequest(params)
        });
    }
    //切换 Panel
    handleChangePan = (e)=>{
        //console.log(e)
    }

    /*查询用户简历基础信息*/
    resumeBaseRequest = (params)=>{
        this.setState({
            loading:true,
            loadingTxt:'加载中...'
        })
        Axios.get({
            block:'/hr',
            url:'/user/resume',
            params:params,
        }).then((data)=>{
           // console.log(data)
            let resumeBaseInfo = data.data||null;
            this.setState({
                loading:false,
                resumeBaseInfo,
            })
            if (resumeBaseInfo) {
                //查询简历项
                let resItem = ["JOB","EDU","TRAIN","FURTHER_EDU","CERTIFICATE"]
                for (let i = 0; i < resItem.length; i++) {
                    let item = resItem[i];
                    let _params = {
                        resumeId:resumeBaseInfo.id,
                        type:item,
                    }
                    this.resumeItemRequest(_params)
                }
            }
        }).catch((error)=>{
            this.setState({ loading:false })
            console.log(error);
        })
    }
    /*创建或更新简历基础信息 请求*/
    updateInfoRequest = (params)=>{
        this.setState({
            updateInfoModal:{
                ...this.state.updateInfoModal,
                confirmLoading: true,
            }
        })
        Axios.post({
            block:'/hr',
            url:'/user/resume',
            params:params,
        }).then((data)=>{
            //console.log(data)
            this.setState({
                updateInfoModal:{
                    ...this.state.updateInfoModal,
                    visible: false,
                    confirmLoading: false,
                }
            },()=>{
                message.success('简历基础信息更新成功！',2,()=>{
                    //let _params = Utils.FilterParam(this.initParams); //过滤掉为空的参数
                    let id = this.props.id;
                    if(id){
                        let _params = { userId:id, }
                        this.resumeBaseRequest(_params);
                    }
                    //window.location.reload()
                });
            })
        }).catch((error)=>{
            console.log(error);
            this.setState({
                updateInfoModal:{
                    ...this.state.updateInfoModal,
                    confirmLoading: false,
                }
            })
        })
    }
    /*创建用户简历项 请求*/
    createMoreInfoRequest = (params)=>{
        this.setState({
            moreInfoModal:{
                ...this.state.moreInfoModal,
                confirmLoading: true,
            }
        })
        Axios.post({
            block:'/hr',
            url:'/user/resumeItem',
            params:params,
        }).then((data)=>{
            //console.log(data)
            this.setState({
                moreInfoModal:{
                    ...this.state.moreInfoModal,
                    visible: false,
                    confirmLoading: false,
                }
            },()=>{
                message.success('添加补充信息成功！',2,()=>{
                    //window.location.reload()
                });
                let _params = {
                    resumeId:this.state.resumeBaseInfo.id,
                    type:params.type,
                }
                this.resumeItemRequest(_params)
            })
        }).catch((error)=>{
            //console.log(error);
            this.setState({
                moreInfoModal:{
                    ...this.state.moreInfoModal,
                    confirmLoading: false,
                }
            })
        })
    }
    /*删除用户简历项*/
    handleDelResumeItem = (id,type)=>{
        Modal.confirm({
            title: '确认删除？',
            content: <div>确认删除？删除后数据不可恢复!</div>,
            okText:'确认',
            cancelText:'取消',
            onOk:()=>{
                let params = {
                    id,
                    type,
                }
                this.delResumeItemRequest(params);
            }
        })
    }
    /*查询用户简历项列表*/
    resumeItemRequest = (params)=>{
        this.setState({
            loading:true,
            loadingTxt:'加载中...'
        })
        Axios.get({
            block:'/hr',
            url:'/user/resumeItem',
            params:params,
        }).then((data)=>{
            //console.log(data)
            //console.log(params)
            if (params.type=="JOB") {
                let JOB_data = data.data;
                this.setState({ JOB_data, })
            }else if (params.type=="EDU") {
                let EDU_data = data.data;
                this.setState({ EDU_data, })
            }else if (params.type=="TRAIN") {
                let TRAIN_data = data.data;
                this.setState({ TRAIN_data, })
            }else if (params.type=="FURTHER_EDU") {
                let FURTHER_EDU_data = data.data;
                this.setState({ FURTHER_EDU_data, })
            }else if (params.type=="CERTIFICATE") {
                let CERTIFICATE_data = data.data;
                this.setState({ CERTIFICATE_data, })
            }
            this.setState({
                loading:false,
            })

        }).catch((error)=>{
            this.setState({ loading:false })
            console.log(error);
        })
    }
    /*删除用户用户简历项*/
    delResumeItemRequest = (params) => {
        this.setState({
            loading: true,
            loadingTxt: '删除中...'
        })
        Axios.delete({
            block: '/hr',
            url: '/user/resumeItem',
            params: params,
        }).then((data) => {
           // console.log(data);
            this.setState({loading: false})
            message.success('删除成功！', 2, () => {
            });
            let _params = {
                resumeId:this.state.resumeBaseInfo.id,
                type:params.type,
            }
            this.resumeItemRequest(_params)
        }).catch((error) => {
            this.setState({loading: false})
            console.log(error);
        })
    }
    render(){
        const resumeBascInfo = this.state.resumeBaseInfo||null;
        const genderDic = {
            'MAN':'男',
            'WOMAN':'女',
            'SECRECY':'保密',
        }
        const JOB_data = this.state.JOB_data||[];
        const EDU_data = this.state.EDU_data||[];
        const TRAIN_data = this.state.TRAIN_data||[];
        const FURTHER_EDU_data = this.state.FURTHER_EDU_data||[];
        const CERTIFICATE_data = this.state.CERTIFICATE_data||[];
        return(
            <Spin spinning={this.state.loading} size="large" tip={this.state.loadingTxt}>
                <div className="resume-box">
                    <Card title="基础资料"
                          bordered={false}
                          bodyStyle={{paddingLeft:0,paddingRight:0}}
                          headStyle={{paddingLeft:0,paddingRight:0}}
                          extra={<a href="javascript:;" className="btn-txt-primary" onClick={this.handleUpdateBaseInfo}>编辑基础资料</a>}>
                        {
                            resumeBascInfo?
                                <table className="common-dataTab" border="1">
                                    <tbody>
                                    <tr>
                                        <th>姓名</th>
                                        <td>{resumeBascInfo.realname?resumeBascInfo.realname:'—'}</td>
                                        <th>性别</th>
                                        <td>{genderDic[resumeBascInfo.gender]}</td>
                                        <th>手机号码</th>
                                        <td>{resumeBascInfo.mobile?resumeBascInfo.mobile:'—'}</td>
                                        <th>邮箱</th>
                                        <td>{resumeBascInfo.email?resumeBascInfo.email:'—'}</td>
                                    </tr>
                                    <tr>
                                        <th>座机</th>
                                        <td>{resumeBascInfo.tel?resumeBascInfo.tel:'—'}</td>
                                        <th>通信地址</th>
                                        <td>{resumeBascInfo.address?resumeBascInfo.address:'—'}</td>
                                        <th>微信</th>
                                        <td>{resumeBascInfo.wechat?resumeBascInfo.wechat:'—'}</td>
                                        <th>qq</th>
                                        <td>{resumeBascInfo.qq?resumeBascInfo.qq:'—'}</td>
                                    </tr>
                                    <tr>
                                        <th>名族</th>
                                        <td>{resumeBascInfo.nationality?resumeBascInfo.nationality:'—'}</td>
                                        <th>籍贯</th>
                                        <td>{resumeBascInfo.birthPlace?resumeBascInfo.birthPlace:'—'}</td>
                                        <th>政治面貌</th>
                                        <td>{resumeBascInfo.politicalStatus?resumeBascInfo.politicalStatus:'—'}</td>
                                        <th>生日</th>
                                        <td>{resumeBascInfo.birthDate?resumeBascInfo.birthDate:'—'}</td>
                                    </tr>
                                    <tr>
                                        <th>婚姻状态</th>
                                        <td>{resumeBascInfo.marriageStatus?resumeBascInfo.marriageStatus:'—'}</td>
                                        <th>身份证</th>
                                        <td>{resumeBascInfo.idcard?resumeBascInfo.idcard:'—'}</td>
                                        <th>学历</th>
                                        <td>{resumeBascInfo.eduBackground?resumeBascInfo.eduBackground:'—'}</td>
                                        <th>毕业学校</th>
                                        <td>{resumeBascInfo.eduSchool?resumeBascInfo.eduSchool:'—'}</td>
                                    </tr>
                                    <tr>
                                        <th>学制</th>
                                        <td>{resumeBascInfo.eduSystem?resumeBascInfo.eduSystem:'—'}</td>
                                        <th>学位</th>
                                        <td>{resumeBascInfo.eduQualification?resumeBascInfo.eduQualification:'—'}</td>
                                        <th>专业</th>
                                        <td>{resumeBascInfo.eduMajor?resumeBascInfo.eduMajor:'—'}</td>
                                        <th>毕业时间</th>
                                        <td>{resumeBascInfo.eduGraduateTime?moment(resumeBascInfo.eduGraduateTime).format("YYYY-MM-DD"):'—'}</td>
                                    </tr>
                                    <tr>
                                        <th>开始工作时间</th>
                                        <td>{resumeBascInfo.beginJobTime?moment(resumeBascInfo.beginJobTime).format("YYYY-MM-DD"):'—'}</td>
                                        <th>本行工作时间</th>
                                        <td>{resumeBascInfo.beginIndustryJobTime?moment(resumeBascInfo.beginIndustryJobTime).format("YYYY-MM-DD"):'—'}</td>
                                        <th>身高</th>
                                        <td>{resumeBascInfo.height?resumeBascInfo.height:'—'}</td>
                                        <th>体重</th>
                                        <td>{resumeBascInfo.weight?resumeBascInfo.weight:'—'}</td>
                                    </tr>
                                    <tr>
                                        <th>身体状态</th>
                                        <td>{resumeBascInfo.physicalStatus?resumeBascInfo.physicalStatus:'—'}</td>
                                        <th>特长</th>
                                        <td>{resumeBascInfo.specialty?resumeBascInfo.specialty:'—'}</td>
                                        <th>奖励</th>
                                        <td>{resumeBascInfo.rewards?resumeBascInfo.rewards:'—'}</td>
                                        <th>惩罚</th>
                                        <td>{resumeBascInfo.punishment?resumeBascInfo.punishment:'—'}</td>
                                    </tr>
                                    </tbody>
                                </table>:<div style={{textAlign:"center"}}>暂无简历信息</div>
                        }

                    </Card>
                    {
                        resumeBascInfo?
                            <Card
                                title="补充信息"
                                bordered={false}
                                bodyStyle={{paddingLeft:0,paddingRight:0}}
                                headStyle={{paddingLeft:0,paddingRight:0}}
                                extra={<a href="javascript:;" className="btn-txt-primary" onClick={this.handleAddInfo}>添加补充信息</a>}>
                                <Collapse bordered={false} onChange={(e)=>this.handleChangePan(e)}>
                                    <Panel header="工作经历" key="JOB">
                                        {
                                            JOB_data.length?
                                            JOB_data.map((item,index)=>{
                                                return (
                                                    <Card
                                                        title={item.title}
                                                        bordered={false}
                                                        key={index}
                                                        extra={<a href="javascript:;" onClick={() => this.handleDelResumeItem(item.id,"JOB")} className="btn-txt-danger">删除</a>}
                                                    >
                                                        <Row style={{marginBottom:15}}>
                                                            <Col sm={8} className="item"><span>{moment(item.beginTime).format('YYYY-MM-DD')} - {item.endTime?moment(item.endTime).format('YYYY-MM-DD'):"至今"}</span></Col>
                                                            <Col sm={8} className="item"><span>{item.companyName}</span></Col>
                                                            <Col sm={8} className="item"><span>{item.department} {item.position?" 担任 "+item.position:""}</span></Col>
                                                        </Row>
                                                        <Row>
                                                            <Col sm={24} className="item"><span>{item.content}</span></Col>
                                                        </Row>
                                                    </Card>
                                                )
                                            })
                                                :<div style={{textAlign:"center"}}>暂无工作经历</div>
                                        }
                                    </Panel>
                                    <Panel header="教育经历" key="EDU">
                                        {
                                            EDU_data.length?
                                                EDU_data.map((item,index)=>{
                                                    return (
                                                        <Card
                                                            title={item.title}
                                                            bordered={false}
                                                            key={index}
                                                            extra={<a href="javascript:;" onClick={() => this.handleDelResumeItem(item.id,"EDU")} className="btn-txt-danger">删除</a>}
                                                        >
                                                            <Row style={{marginBottom:15}}>
                                                                <Col sm={8} className="item"><span>{moment(item.beginTime).format('YYYY-MM-DD')} - {item.endTime?moment(item.endTime).format('YYYY-MM-DD'):"至今"}</span></Col>
                                                                <Col sm={8} className="item"><span>{item.companyName}</span></Col>
                                                                <Col sm={8} className="item"><span>{item.department}</span></Col>
                                                            </Row>
                                                            <Row>
                                                                <Col sm={24} className="item"><span>{item.content}</span></Col>
                                                            </Row>
                                                        </Card>
                                                    )
                                                })
                                                :<div style={{textAlign:"center"}}>暂无教育经历</div>
                                        }
                                    </Panel>
                                    <Panel header="培训经历" key="TRAIN">
                                        {
                                            TRAIN_data.length?
                                                TRAIN_data.map((item,index)=>{
                                                    return (
                                                        <Card
                                                            title={item.title}
                                                            bordered={false}
                                                            key={index}
                                                            extra={<a href="javascript:;" onClick={() => this.handleDelResumeItem(item.id,"TRAIN")} className="btn-txt-danger">删除</a>}
                                                        >
                                                            <Row style={{marginBottom:15}}>
                                                                <Col sm={8} className="item"><span>{moment(item.beginTime).format('YYYY-MM-DD')} - {item.endTime?moment(item.endTime).format('YYYY-MM-DD'):"至今"}</span></Col>
                                                                <Col sm={8} className="item"><span>{item.companyName}</span></Col>
                                                            </Row>
                                                            <Row>
                                                                <Col sm={24} className="item"><span>{item.content}</span></Col>
                                                            </Row>
                                                        </Card>
                                                    )
                                                })
                                                :<div style={{textAlign:"center"}}>暂无培训经历</div>
                                        }
                                    </Panel>
                                    <Panel header="进修进取经历" key="FURTHER_EDU">
                                        {
                                            FURTHER_EDU_data.length?
                                                FURTHER_EDU_data.map((item,index)=>{
                                                    return (
                                                        <Card
                                                            title={item.title}
                                                            bordered={false}
                                                            key={index}
                                                            extra={<a href="javascript:;" onClick={() => this.handleDelResumeItem(item.id,"FURTHER_EDU")} className="btn-txt-danger">删除</a>}
                                                        >
                                                            <Row style={{marginBottom:15}}>
                                                                <Col sm={8} className="item"><span>{moment(item.beginTime).format('YYYY-MM-DD')} - {item.endTime?moment(item.endTime).format('YYYY-MM-DD'):"至今"}</span></Col>
                                                                <Col sm={8} className="item"><span>{item.companyName}</span></Col>
                                                            </Row>
                                                            <Row>
                                                                <Col sm={24} className="item"><span>{item.content}</span></Col>
                                                            </Row>
                                                        </Card>
                                                    )
                                                })
                                                :<div style={{textAlign:"center"}}>暂无进修进取经历</div>
                                        }
                                    </Panel>
                                    <Panel header="考证情况" key="CERTIFICATE">
                                        {
                                            CERTIFICATE_data.length?
                                                CERTIFICATE_data.map((item,index)=>{
                                                    return (
                                                        <Card
                                                            title={item.title}
                                                            bordered={false}
                                                            key={index}
                                                            extra={<a href="javascript:;" onClick={() => this.handleDelResumeItem(item.id,"CERTIFICATE")} className="btn-txt-danger">删除</a>}
                                                        >
                                                            <Row style={{marginBottom:15}}>
                                                                <Col sm={8} className="item"><span>{moment(item.beginTime).format('YYYY-MM-DD')} - {item.endTime?moment(item.endTime).format('YYYY-MM-DD'):"至今"}</span></Col>
                                                                <Col sm={8} className="item"><span>{item.companyName}</span></Col>
                                                            </Row>
                                                            <Row>
                                                                <Col sm={24} className="item"><span>{item.content}</span></Col>
                                                            </Row>
                                                        </Card>
                                                    )
                                                })
                                                :<div style={{textAlign:"center"}}>暂无考证情况</div>
                                        }
                                    </Panel>
                                </Collapse>
                            </Card>:""
                    }
                    <Modal title="简历基础信息"
                           width={1200}
                           visible={this.state.updateInfoModal.visible}
                           onOk={this.handleUpdateInfoSubmit}
                           okText="确认修改"
                           confirmLoading={this.state.updateInfoModal.confirmLoading}
                           onCancel={()=>{
                               this.setState({
                                   updateInfoModal:{
                                       ...this.state.updateInfoModal,
                                       visible:false
                                   }
                               })
                           }}
                           destroyOnClose={true}
                    >
                        <UpdateInfoForm
                            baseInfo={this.props.baseInfo}
                            resumeBaseInfo={this.state.resumeBaseInfo}
                            wrappedComponentRef={(updateInfoForm)=>{this.updateInfoForm = updateInfoForm;}}/>
                    </Modal>
                    <Modal title="补充信息编辑"
                           visible={this.state.moreInfoModal.visible}
                           onOk={this.handleMoreInfoSubmit}
                           okText="确认"
                           confirmLoading={this.state.moreInfoModal.confirmLoading}
                           onCancel={()=>{
                               this.setState({
                                   moreInfoModal:{
                                       ...this.state.moreInfoModal,
                                       visible:false
                                   }
                               })
                           }}
                           destroyOnClose={true}
                    >
                        <MoreInfoForm
                            resumeBaseInfo={this.state.resumeBaseInfo}
                            wrappedComponentRef={(moreInfoForm)=>{this.moreInfoForm = moreInfoForm;}}/>
                    </Modal>
                </div>
            </Spin>
        )
    }
}


//更新用户基础简历表单
class UpdateInfoForm extends React.Component{
    state = {}
    componentWillMount(){
    }
    render(){
        const { getFieldDecorator } = this.props.form;
        const formItemLayout = {
            labelCol: {span: 7},
            wrapperCol: {span: 16}
        };
        let baseInfo = this.props.baseInfo||{};   //用户详情
            baseInfo.userId = baseInfo.id
               // delete baseInfo.id;
        const resumeBaseInfo = this.props.resumeBaseInfo;   //简历基本信息
        const info = resumeBaseInfo?resumeBaseInfo:baseInfo;    // resumeBaseInfo 为空代表为创建基础简历
        return (
            <div className="layout-form-three">
                <div className="left-div" style={{minWidth:375}}>
                    <Form>
                        <FormItem {...formItemLayout} style={{display:'none'}}>
                            {
                                getFieldDecorator('userId',{
                                    initialValue:info.userId
                                })(
                                    <Input type="hidden" placeholder=""/>
                                )
                            }
                        </FormItem>
                        <FormItem label="姓名" {...formItemLayout}>
                            {
                                getFieldDecorator('realname',{
                                    initialValue:info.realname,
                                    rules: [{ required: true, message: '请填写姓名!' }],
                                })(
                                    <Input type="text" placeholder="姓名"/>
                                )
                            }
                        </FormItem>
                        <FormItem label="性别" {...formItemLayout}>
                            {
                                getFieldDecorator('gender',{
                                    initialValue:info.gender,
                                    rules: [{ required: true, message: '请选择性别!' }],
                                })(
                                    <RadioGroup>
                                        <Radio value="MAN">男</Radio>
                                        <Radio value="WOMAN">女</Radio>
                                        <Radio value="SECRECY">保密</Radio>
                                    </RadioGroup>
                                )
                            }
                        </FormItem>
                        <FormItem label="手机号码" {...formItemLayout}>
                            {
                                getFieldDecorator('mobile',{
                                    initialValue:info.mobile,
                                    rules: [
                                        { required: true, message: '请填写手机号码!' },
                                        { pattern:mobileRegex,message:"手机号格式不正确"}
                                    ],
                                })(
                                    <Input type="text" placeholder="手机号码（格式：13612341234）"/>
                                )
                            }
                        </FormItem>
                        <FormItem label="邮箱" {...formItemLayout}>
                            {
                                getFieldDecorator('email',{
                                    initialValue:info.email,
                                    rules: [
                                        { required: true, message: '请填写邮箱!' },
                                        { type: 'email', message: '邮箱格式不正确!',}
                                        ],
                                })(
                                    <Input type="text" placeholder="邮箱"/>
                                )
                            }
                        </FormItem>
                        <FormItem label="座机" {...formItemLayout}>
                            {
                                getFieldDecorator('tel',{
                                    initialValue:info.tel,
                                })(
                                    <Input type="text" placeholder="座机（格式：区号-12341234）"/>
                                )
                            }
                        </FormItem>
                        <FormItem label="通信地址" {...formItemLayout}>
                            {
                                getFieldDecorator('address',{
                                    initialValue:info.address,
                                })(
                                    <TextArea type="text" placeholder="通信地址" autosize/>
                                )
                            }
                        </FormItem>
                        <FormItem label="微信" {...formItemLayout}>
                            {
                                getFieldDecorator('wechat',{
                                    initialValue:info.wechat,
                                })(
                                    <Input type="text" placeholder="微信"/>
                                )
                            }
                        </FormItem>
                        <FormItem label="qq" {...formItemLayout}>
                            {
                                getFieldDecorator('qq',{
                                    initialValue:info.qq,
                                })(
                                    <Input type="text" placeholder="qq"/>
                                )
                            }
                        </FormItem>
                        <FormItem label="名族" {...formItemLayout}>
                            {
                                getFieldDecorator('nationality',{
                                    initialValue:info.nationality,
                                })(
                                    <TextArea type="text" placeholder="名族" autosize/>
                                )
                            }
                        </FormItem>
                    </Form>
                </div>
                <div className="middle-div" style={{minWidth:375}}>
                    <Form>
                        <FormItem label="籍贯" {...formItemLayout}>
                            {
                                getFieldDecorator('birthPlace',{
                                    initialValue:info.birthPlace,
                                })(
                                    <Input type="text" placeholder="籍贯"/>
                                )
                            }
                        </FormItem>
                        <FormItem label="政治面貌" {...formItemLayout}>
                            {
                                getFieldDecorator('politicalStatus',{
                                    initialValue:info.politicalStatus,
                                })(
                                    <Select placeholder="政治面貌">
                                        <Option value="党员">党员</Option>
                                        <Option value="预备党员">预备党员</Option>
                                        <Option value="共青团员">共青团员</Option>
                                        <Option value="群众">群众</Option>
                                    </Select>
                                )
                            }
                        </FormItem>
                        <FormItem label="生日" {...formItemLayout}>
                            {
                                getFieldDecorator('birthDate',{
                                    initialValue:info.birthDate?moment(info.birthDate):null,
                                    rules: [{ required: true, message: '请填写生日!' }],
                                })(
                                    <DatePicker
                                        format="YYYY-MM-DD"
                                        placeholder="生日"
                                    />
                                )
                            }
                        </FormItem>
                        <FormItem label="婚姻状态" {...formItemLayout}>
                            {
                                getFieldDecorator('marriageStatus',{
                                    initialValue:info.marriageStatus,
                                })(
                                    <Input type="text" placeholder="婚姻状态"/>
                                )
                            }
                        </FormItem>
                        <FormItem label="身份证" {...formItemLayout}>
                            {
                                getFieldDecorator('idcard',{
                                    initialValue:info.idcard,
                                    rules:[{ pattern:idCardRegex,message:"身份证号码格式不正确"}],
                                })(
                                    <Input type="text" placeholder="身份证"/>
                                )
                            }
                        </FormItem>
                        <FormItem label="学历" {...formItemLayout}>
                            {
                                getFieldDecorator('eduBackground',{
                                    initialValue:info.eduBackground,
                                })(
                                    <Input type="text" placeholder="学历"/>
                                )
                            }
                        </FormItem>
                        <FormItem label="毕业学校" {...formItemLayout}>
                            {
                                getFieldDecorator('eduSchool',{
                                    initialValue:info.eduSchool,
                                })(
                                    <Input type="text" placeholder="毕业学校"/>
                                )
                            }
                        </FormItem>
                        <FormItem label="学制" {...formItemLayout}>
                            {
                                getFieldDecorator('eduSystem',{
                                    initialValue:info.eduSystem,
                                })(
                                    <Input type="text" placeholder="学制"/>
                                )
                            }
                        </FormItem>
                        <FormItem label="学位" {...formItemLayout}>
                            {
                                getFieldDecorator('eduQualification',{
                                    initialValue:info.eduQualification,
                                })(
                                    <Input type="text" placeholder="学位"/>
                                )
                            }
                        </FormItem>
                    </Form>
                </div>
                <div className="right-div" style={{minWidth:375}}>
                    <Form>
                        <FormItem label="专业" {...formItemLayout}>
                            {
                                getFieldDecorator('eduMajor',{
                                    initialValue:info.eduMajor,
                                })(
                                    <Input type="text" placeholder="专业"/>
                                )
                            }
                        </FormItem>
                        <FormItem label="毕业时间" {...formItemLayout}>
                            {
                                getFieldDecorator('eduGraduateTime',{
                                    initialValue:info.eduGraduateTime?moment(info.eduGraduateTime):null,
                                })(
                                    <DatePicker
                                        format="YYYY-MM-DD"
                                        placeholder="毕业时间"
                                    />
                                )
                            }
                        </FormItem>
                        <FormItem label="开始工作时间" {...formItemLayout}>
                            {
                                getFieldDecorator('beginJobTime',{
                                    initialValue:info.beginJobTime?moment(info.beginJobTime):null,
                                    rules: [{ required: true, message: '请填写开始工作时间!' }],
                                })(
                                    <DatePicker
                                        format="YYYY-MM-DD"
                                        placeholder="开始工作时间"
                                    />
                                )
                            }
                        </FormItem>
                        <FormItem label="本行工作时间" {...formItemLayout}>
                            {
                                getFieldDecorator('beginIndustryJobTime',{
                                    initialValue:info.beginIndustryJobTime?moment(info.beginIndustryJobTime):null,
                                    rules: [{ required: true, message: '请填写本行工作时间!' }],
                                })(
                                    <DatePicker
                                        format="YYYY-MM-DD"
                                        placeholder="本行工作时间"
                                    />
                                )
                            }
                        </FormItem>
                        <FormItem label="身高" {...formItemLayout}>
                            {
                                getFieldDecorator('height',{
                                    initialValue:info.height!=0?info.height:'',
                                })(
                                    <Input type="text" placeholder="身高/cm"/>
                                )
                            }
                        </FormItem>
                        <FormItem label="体重" {...formItemLayout}>
                            {
                                getFieldDecorator('weight',{
                                    initialValue:info.weight!=0?info.weight:'',
                                })(
                                    <Input type="text" placeholder="体重/kg"/>
                                )
                            }
                        </FormItem>
                        <FormItem label="身体状态" {...formItemLayout}>
                            {
                                getFieldDecorator('physicalStatus',{
                                    initialValue:info.physicalStatus,
                                })(
                                    <Input type="text" placeholder="身体状态"/>
                                )
                            }
                        </FormItem>
                        <FormItem label="特长" {...formItemLayout}>
                            {
                                getFieldDecorator('specialty',{
                                    initialValue:info.specialty,
                                })(
                                    <TextArea type="text" placeholder="特长" autosize/>
                                )
                            }
                        </FormItem>
                        <FormItem label="奖励" {...formItemLayout}>
                            {
                                getFieldDecorator('rewards',{
                                    initialValue:info.rewards,
                                })(
                                    <TextArea type="text" placeholder="奖励" autosize/>
                                )
                            }
                        </FormItem>
                        <FormItem label="惩罚" {...formItemLayout}>
                            {
                                getFieldDecorator('punishment',{
                                    initialValue:info.punishment,
                                })(
                                    <TextArea type="text" placeholder="惩罚" autosize/>
                                )
                            }
                        </FormItem>
                    </Form>
                </div>
            </div>
        );
    }
}
UpdateInfoForm = Form.create({})(UpdateInfoForm);

//编辑简历项表单
class MoreInfoForm extends React.Component{
    state = {
        type:'JOB',
    }
    componentWillMount(){
    }
    handleChange = (val)=>{
        this.setState({
            type:val
        })
    }
    render(){
        const { getFieldDecorator } = this.props.form;
        const formItemLayout = {
            labelCol: {span: 7},
            wrapperCol: {span: 16}
        };
        const type = this.state.type;
        const resumeId = this.props.resumeBaseInfo.id;
        return (
            <div>
                <Form>
                    <FormItem label="简历编号" {...formItemLayout} style={{display:"none"}}>
                        {
                            getFieldDecorator('resumeId',{
                                initialValue:resumeId
                            })(
                                <Input type="hidden" placeholder=""/>
                            )
                        }
                    </FormItem>
                    <FormItem label="补充信息类型" {...formItemLayout}>
                        {
                            getFieldDecorator('type',{
                                initialValue:"JOB"
                            })(
                                <Select placeholder="补充信息类型" style={{minWidth:150}} onChange={(val)=>this.handleChange(val)}>
                                    <Option key="JOB" value="JOB">工作经历</Option>
                                    <Option key="EDU" value="EDU">教育经历</Option>
                                    <Option key="TRAIN" value="TRAIN">培训经历</Option>
                                    <Option key="FURTHER_EDU" value="FURTHER_EDU">进修进取经历</Option>
                                    <Option key="CERTIFICATE" value="CERTIFICATE">考证情况</Option>
                                </Select>
                            )
                        }
                    </FormItem>
                </Form>
                {
                    type=='JOB'?
                        <Form>
                            <FormItem {...formItemLayout} style={{display:'none'}}>
                                {
                                    getFieldDecorator('id',{
                                    })(
                                        <Input type="hidden" placeholder=""/>
                                    )
                                }
                            </FormItem>
                            <FormItem label="标题" {...formItemLayout}>
                                {
                                    getFieldDecorator('title',{
                                        rules: [{ required: true, message: '请填写标题!' }],
                                    })(
                                        <Input type="text" placeholder="标题"/>
                                    )
                                }
                            </FormItem>
                            <FormItem label="所在公司" {...formItemLayout}>
                                {
                                    getFieldDecorator('companyName',{
                                        rules: [{ required: true, message: '请填写所在公司!' }],
                                    })(
                                        <Input type="text" placeholder="所在公司"/>
                                    )
                                }
                            </FormItem>
                            <FormItem label="所在部门" {...formItemLayout}>
                                {
                                    getFieldDecorator('department',{
                                        rules: [{ required: true, message: '请填写所在部门!' }],
                                    })(
                                        <Input type="text" placeholder="所在部门"/>
                                    )
                                }
                            </FormItem>
                            <FormItem label="开始时间" {...formItemLayout}>
                                {
                                    getFieldDecorator('beginTime',{
                                        rules: [{ required: true, message: '请选择开始时间!' }],
                                    })(
                                        <DatePicker
                                            format="YYYY-MM-DD"
                                            placeholder="开始时间"
                                        />
                                    )
                                }
                            </FormItem>
                            <FormItem label="结束时间" {...formItemLayout}>
                                {
                                    getFieldDecorator('endTime',{
                                    })(
                                        <DatePicker
                                            format="YYYY-MM-DD"
                                            placeholder="结束时间"
                                        />
                                    )
                                }
                            </FormItem>
                            <FormItem label="职务" {...formItemLayout}>
                                {
                                    getFieldDecorator('position',{
                                    })(
                                        <Input type="text" placeholder="职务"/>
                                    )
                                }
                            </FormItem>
                            <FormItem label="内容描述" {...formItemLayout}>
                                {
                                    getFieldDecorator('content',{
                                        rules: [{ required: true, message: '请填写内容描述!' }],
                                    })(
                                        <TextArea type="text" placeholder="内容描述（工作描述等）" autosize/>
                                    )
                                }
                            </FormItem>
                        </Form>
                        :<div></div>
                }
                {/*教育经历*/}
                {
                    type=='EDU'?
                        <Form>
                            <FormItem {...formItemLayout} style={{display:'none'}}>
                                {
                                    getFieldDecorator('id',{
                                    })(
                                        <Input type="hidden" placeholder=""/>
                                    )
                                }
                            </FormItem>
                            <FormItem label="标题" {...formItemLayout}>
                                {
                                    getFieldDecorator('title',{
                                        rules: [{ required: true, message: '请填写标题!' }],
                                    })(
                                        <Input type="text" placeholder="标题"/>
                                    )
                                }
                            </FormItem>
                            <FormItem label="学校" {...formItemLayout}>
                                {
                                    getFieldDecorator('companyName',{
                                        rules: [{ required: true, message: '请填写学校!' }],
                                    })(
                                        <Input type="text" placeholder="学校"/>
                                    )
                                }
                            </FormItem>
                            <FormItem label="专业" {...formItemLayout}>
                                {
                                    getFieldDecorator('department',{
                                        rules: [{ required: true, message: '请填写专业!' }],
                                    })(
                                        <Input type="text" placeholder="专业"/>
                                    )
                                }
                            </FormItem>
                            <FormItem label="开始时间" {...formItemLayout}>
                                {
                                    getFieldDecorator('beginTime',{
                                        rules: [{ required: true, message: '请选择开始时间!' }],
                                    })(
                                        <DatePicker
                                            format="YYYY-MM-DD"
                                            placeholder="开始时间"
                                        />
                                    )
                                }
                            </FormItem>
                            <FormItem label="结束时间" {...formItemLayout}>
                                {
                                    getFieldDecorator('endTime',{
                                    })(
                                        <DatePicker
                                            format="YYYY-MM-DD"
                                            placeholder="结束时间"
                                        />
                                    )
                                }
                            </FormItem>
                            <FormItem label="内容描述" {...formItemLayout}>
                                {
                                    getFieldDecorator('content',{
                                        rules: [{ required: true, message: '请填写内容描述!' }],
                                    })(
                                        <TextArea type="text" placeholder="内容描述（教育经历描述）" autosize/>
                                    )
                                }
                            </FormItem>
                        </Form>
                        :<div></div>
                }
                {/*培训经历*/}
                {
                    type=='TRAIN'?
                        <Form>
                            <FormItem {...formItemLayout} style={{display:'none'}}>
                                {
                                    getFieldDecorator('id',{
                                    })(
                                        <Input type="hidden" placeholder=""/>
                                    )
                                }
                            </FormItem>
                            <FormItem label="标题" {...formItemLayout}>
                                {
                                    getFieldDecorator('title',{
                                        rules: [{ required: true, message: '请填写标题!' }],
                                    })(
                                        <Input type="text" placeholder="标题"/>
                                    )
                                }
                            </FormItem>
                            <FormItem label="培训机构" {...formItemLayout}>
                                {
                                    getFieldDecorator('companyName',{
                                        rules: [{ required: true, message: '请填写培训机构!' }],
                                    })(
                                        <Input type="text" placeholder="培训机构"/>
                                    )
                                }
                            </FormItem>
                            <FormItem label="开始时间" {...formItemLayout}>
                                {
                                    getFieldDecorator('beginTime',{
                                        rules: [{ required: true, message: '请选择开始时间!' }],
                                    })(
                                        <DatePicker
                                            format="YYYY-MM-DD"
                                            placeholder="开始时间"
                                        />
                                    )
                                }
                            </FormItem>
                            <FormItem label="结束时间" {...formItemLayout}>
                                {
                                    getFieldDecorator('endTime',{
                                    })(
                                        <DatePicker
                                            format="YYYY-MM-DD"
                                            placeholder="结束时间"
                                        />
                                    )
                                }
                            </FormItem>
                            <FormItem label="内容描述" {...formItemLayout}>
                                {
                                    getFieldDecorator('content',{
                                        rules: [{ required: true, message: '请填写内容描述!' }],
                                    })(
                                        <TextArea type="text" placeholder="内容描述（培训经历描述）" autosize/>
                                    )
                                }
                            </FormItem>
                        </Form>
                        :<div></div>
                }
                {/*进修进取经历*/}
                {
                    type=='FURTHER_EDU'?
                        <Form>
                            <FormItem {...formItemLayout} style={{display:'none'}}>
                                {
                                    getFieldDecorator('id',{
                                    })(
                                        <Input type="hidden" placeholder=""/>
                                    )
                                }
                            </FormItem>
                            <FormItem label="标题" {...formItemLayout}>
                                {
                                    getFieldDecorator('title',{
                                        rules: [{ required: true, message: '请填写标题!' }],
                                    })(
                                        <Input type="text" placeholder="标题"/>
                                    )
                                }
                            </FormItem>
                            <FormItem label="所在机构" {...formItemLayout}>
                                {
                                    getFieldDecorator('companyName',{
                                        rules: [{ required: true, message: '请填写所在机构!' }],
                                    })(
                                        <Input type="text" placeholder="所在机构"/>
                                    )
                                }
                            </FormItem>
                            <FormItem label="开始时间" {...formItemLayout}>
                                {
                                    getFieldDecorator('beginTime',{
                                        rules: [{ required: true, message: '请选择开始时间!' }],
                                    })(
                                        <DatePicker
                                            format="YYYY-MM-DD"
                                            placeholder="开始时间"
                                        />
                                    )
                                }
                            </FormItem>
                            <FormItem label="结束时间" {...formItemLayout}>
                                {
                                    getFieldDecorator('endTime',{
                                    })(
                                        <DatePicker
                                            format="YYYY-MM-DD"
                                            placeholder="结束时间"
                                        />
                                    )
                                }
                            </FormItem>
                            <FormItem label="内容描述" {...formItemLayout}>
                                {
                                    getFieldDecorator('content',{
                                        rules: [{ required: true, message: '请填写内容描述!' }],
                                    })(
                                        <TextArea type="text" placeholder="内容描述（进修进取经历描述）" autosize/>
                                    )
                                }
                            </FormItem>
                        </Form>
                        :<div></div>
                }
                {/*考证情况*/}
                {
                    type=='CERTIFICATE'?
                        <Form>
                            <FormItem {...formItemLayout} style={{display:'none'}}>
                                {
                                    getFieldDecorator('id',{
                                    })(
                                        <Input type="hidden" placeholder=""/>
                                    )
                                }
                            </FormItem>
                            <FormItem label="标题" {...formItemLayout}>
                                {
                                    getFieldDecorator('title',{
                                        rules: [{ required: true, message: '请填写标题!' }],
                                    })(
                                        <Input type="text" placeholder="标题"/>
                                    )
                                }
                            </FormItem>
                            <FormItem label="所在机构" {...formItemLayout}>
                                {
                                    getFieldDecorator('companyName',{
                                        rules: [{ required: true, message: '请填写所在机构!' }],
                                    })(
                                        <Input type="text" placeholder="所在机构"/>
                                    )
                                }
                            </FormItem>
                            <FormItem label="开始时间" {...formItemLayout}>
                                {
                                    getFieldDecorator('beginTime',{
                                        rules: [{ required: true, message: '请选择开始时间!' }],
                                    })(
                                        <DatePicker
                                            format="YYYY-MM-DD"
                                            placeholder="开始时间"
                                        />
                                    )
                                }
                            </FormItem>
                            <FormItem label="结束时间" {...formItemLayout}>
                                {
                                    getFieldDecorator('endTime',{
                                    })(
                                        <DatePicker
                                            format="YYYY-MM-DD"
                                            placeholder="结束时间"
                                        />
                                    )
                                }
                            </FormItem>
                            <FormItem label="内容描述" {...formItemLayout}>
                                {
                                    getFieldDecorator('content',{
                                        rules: [{ required: true, message: '请填写内容描述!' }],
                                    })(
                                        <TextArea type="text" placeholder="内容描述（考证描述）" autosize/>
                                    )
                                }
                            </FormItem>
                        </Form>
                        :<div></div>
                }
            </div>
        );
    }
}
MoreInfoForm = Form.create({})(MoreInfoForm);